import Vue from 'vue'
import Router from 'vue-router'

import OverView from '@/views/report/OverView'
import Bind from '@/views/report/Bind'
import CompanyList from '@/views/report/CompanyList'

import store from '@/store/report/index'
import api from '@/api/base.api'
import {
    routesObj,
    beforeEachHandler
} from '@/router/config'

Vue.use(Router)
var router = new Router({
    routes: [{
            /* 默认首页 */
            path: '/',
            name: 'companyList',
            component: CompanyList
        },
        {
            /* 当前openid绑定企业列表 */
            path: '/companyList',
            name: 'companyList',
            component: CompanyList
        },
        {
            /* 报表详情 */
            path: '/overView/:companyCode/:userCode',
            name: 'overView',
            component: OverView
        },
        {
            /* openid和企业关联页面 */
            path: '/bind',
            name: 'bind',
            component: Bind
        },
        routesObj
    ]
})
router.beforeEach(beforeEachHandler);
router.beforeEach(function (to, from, next) {
    if (to.fullPath == '/companyList') {
        /* 没有查询绑定信息之前 */
        next('/bind');
        
    }
})
export default router